<template>
  <div>
    <div class="find_detail" v-for="item in findInfo">
      <div class="find_detail_time">
        <span class="left">{{item.crtTime | endTimeDianC}}</span>
        <em class="right iconfont icon-guanzhu">{{item.visitCount}}</em>
      </div>
      <div class="clear"></div>
      <h2>{{item.docTitle}}</h2>
      <div class="detail_cont" v-html='item.docContent'></div>
      <a @click="merchDetail(item)" class="look_shop iconfont icon-shanghu-">查看商户</a>
    </div>
  </div>
</template>
<script>
  import getData2 from '../../service/getData2.js'
  import * as types from '../../vuex/types'
  import * as types1 from '../../vuex/appendType'
  import {mapState} from 'vuex'
  import {Toast} from 'mint-ui'
  import {Common} from 'src/utils/common.js'
  import {Storage} from 'src/utils/storage.js'
  import {getCode} from 'src/utils/getCode.js'

  export default {
    name: "findDetail",
    data() {
      return {
        findInfo: ''
      }
    },
    methods: {
      merchDetail(item) {
        if (sessionStorage.getItem('external')) {
          sessionStorage.removeItem('external')
          sessionStorage.setItem('jumpPage', '/merchDetail?mchtId=' + item.mchtId); // 登录后跳转的页面
          getCode()
        } else {
          this.$router.push({name: 'merchDetail', query: {mchtId: item.mchtId}})
        }
      }
    },
    computed: {},
    async created() {
      this.$store.commit("WAIT_LOADING", true); // 翻书动画
      await getData2.visitNum({method: 'post', data: {"docId": this.$route.query.docId}}) // 增加阅读数
      document.body.style.background = '#fff';
      var me = this;
      var rep = await getData2.findDetail({
        docId: me.$route.query.docId
      });
      me.findInfo = rep.content.markeList;
      wx.ready(() => {
        Common.setWechatShare({ //设置分享
          title: me.findInfo[0].docTitle, // 分享标题
          desc: me.findInfo[0].docDesc, // 分享描述
          link: '/findDetail?docId=' + this.$route.query.docId + "&img=" + me.$route.query.img, // 分享链接
          imgUrl: me.$route.query.img, // 分享图片
        })
      })
      if (rep.respCode != '00') {
        Toast({
          message: '操作失败',
          duration: 800
        });
      }
    },
    beforeRouteLeave(to, from, next) {
      document.body.style.background = '#f5f5f5';
      Common.wechatShare(); // 离开时重新设置分享
      next();
    }
  }
</script>
<style>
  .look_shop {
    font-size: 0.85rem
  }
</style>
